import numpy as np


material_list = ['超细玻璃棉毡、管', '矿渣棉', '水泥蛭石制品', '水泥珍珠岩制品',
                 '粉煤灰泡沫砖', '岩棉玻璃布缝板', 'A 级硅藻土制品', 'B 级硅藻土制品',
                 '膨胀珍珠岩', '微孔硅酸钙制品', '耐火黏土砖', '轻质耐火黏土砖',
                 '超轻质耐火黏土砖1', '超轻质耐火黏土砖2', '硅砖', '镁砖',
                 '铬砖',
                 ]

t_max = [400, max(550, 600), 800, 600,
         300, 600, 900, 900,
         1000, 650, max(1350, 1450), max(1250, 1350),
         max(1150, 1300), 1100, 1700, max(1600, 1700),
         max(1600, 1700),
         ]

rho = [np.average((18, 20)), 350, np.average((400, 450)), np.average((300, 400)),
       500, 100, 500, 550,
       55, 250, np.average((1800, 2040)), np.average((800, 1300)),
       np.average((540, 610)), np.average((270, 330)), np.average((1900, 1950)), np.average((2300, 2600)),
       np.average((2600, 2800)),
       ]

# 导热系数 lambda_ = a + b * t
a = [0.033, 0.0674, 0.103, 0.0651,
     0.099, 0.0314, 0.0395, 0.0477,
     0.0424, 0.041, np.average((0.7, 0.84)), np.average((0.29, 0.41)),
     0.093, 0.058, 0.93, 2.1,
     4.7,
     ]

b = [0.00023, 0.000215, 0.000198, 0.000105,
     0.0002, 0.000198, 0.00019, 0.0002,
     0.000137, 0.0002, 0.00058, 0.00026,
     0.00016, 0.00017, 0.0007, 0.00019,
     0.00017,
     ]


def get_lambda_(material, t):
    if material in material_list:
        index = material_list.index(material)
        if t > t_max[index]:
            print('超过最大温度，未知其导热系数')
            return None
        return a[index] + b[index] * t
    else:
        print('附表4里没有找到该材料！')
        return None
